import { useEditor } from '@craftjs/core';
import React from 'react';

export const SettingPanel: React.FC = () => {
  const { settings } = useEditor((state) => {
    const [selectedId] = state.events.selected;
    const node = state.nodes[selectedId];

    return {
      settings: node ? node.related?.settings : null,
    };
  });

  return (
    <div
      style={{
        height: '100%',
        borderLeft: '1px solid #d3d3d3',
        boxSizing: 'border-box',
        overflow: 'auto',
      }}
    >
      {settings ? React.createElement(settings) : null}
    </div>
  );
};
